package com.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class IdUtils {
    public static void main(String[] args) throws Exception{
        System.out.println(autoOrderId());
    }
    public static Integer autoOrderId() throws Exception{
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = format.format(date);
        Date orderId = null;
        Random rand = new Random();
        int x = rand.nextInt(900) + 100; //取一个随机数
        orderId = format.parse(str);
        return Integer.valueOf((String.valueOf(orderId.getTime()) + x).substring(9,16));
    }

}
